class Solution:
    def predictPartyVictory(self, senate: str) -> str:
        # 将索引分为R、D两堆，都为升序排列
        r_idxs,d_idxs = deque(),deque()
        for i in range(len(senate)):
            if senate[i] == 'R':
                r_idxs.append(i)
            else:
                d_idxs.append(i)
        while r_idxs and d_idxs:
            # 各自弹出一个最小索引，谁小谁先投票
            r,d = r_idxs.popleft(),d_idxs.popleft()
            # 谁小保留谁，大的被舍弃
            if r<d:
                r_idxs.append(r+len(senate))  # +n，保证本轮不会再次投票
            else:
                d_idxs.append(d+len(senate))
        return 'Radiant' if r_idxs else 'Dire'